Private diceArray()
Private sum_dice As Integer
Private max_dice As Integer
Private min_dice As Integer
Private average_dice As Single


Private Function dice(end_number As Integer, Optional i_dice As Integer = 1, Optional start_number As Integer = 1)
    Randomize
    Dim i%
    Dim counter()
    diceArray = WorksheetFunction.RandArray(1, i_dice, start_number, end_number, True)
    sum_dice = WorksheetFunction.Sum(diceArray)
    max_dice = WorksheetFunction.Max(diceArray)
    min_dice = WorksheetFunction.Min(diceArray)
    average_dice = WorksheetFunction.RoundDown(WorksheetFunction.Average(diceArray), 0)
End Function

Private Function getMax()
    getMax = max_dice
End Function

Private Function getMin()
    getMin = min_dice
End Function

Private Function getSum()
    getSum = sum_dice
End Function

Private Function getAverage()
    getAverage = average_dice
End Function

Private Function getList()
    getList = diceArray
End Function

Sub 投骰子()
    Dim arr()
    Dim i%
    Dim i_min%, i_max%, i_sum%, i_average%
    
    
    
    dice 150, 6, 80
    i_min = getMin
    i_max = getMax
    i_sum = getSum
    i_average = getAverage
    
    Cells(16, 3).Resize(6, 1) = Application.Transpose(getList)
    Cells(22, 3) = i_sum
    
    '特例人物生成
    'If i_sum > 750 And i_sum < 800 Then
    'Cells(16, 3).Resize(6, 1) = Application.Transpose(getList)
    'Cells(22, 3) = i_sum
    'Else
    'Call 投骰子
    'End If
    
End Sub


Sub test2()
    Debug.Print ActiveCell.Row, ActiveCell.Column
End Sub
